﻿using System.Linq;
using VisualWip.Core.Interfaces;

namespace VisualWip.Core
{
    public class DecresingSizeWorkItemSizeStratergy : IWorkItemSizeStratergy
    {
        private readonly IWorkItemSizeProvider _workItemSizeProvider;

        public DecresingSizeWorkItemSizeStratergy(IWorkItemSizeProvider workItemSizeProvider)
        {
            _workItemSizeProvider = workItemSizeProvider;
        }

        public WorkItemSize NextSize(WorkItemSize size)
        {
            return _workItemSizeProvider.GetSizes().Where(x => x.SortOrder < size.SortOrder).Max() ?? WorkItemSize.Small;
        }
    }
}